#pragma once
#include "../../instrument.h"

namespace gMobilabPlus
{
#ifdef HAVE_GTEC_LIBRARY
#include "gMOBIlabplus.h"
#pragma comment(lib,"gMOBIlabplus.lib")

typedef HANDLE (__stdcall*LibGT_OpenDevice )(LPSTR);
typedef  BOOL  (__stdcall*LibGT_CloseDevice)(HANDLE );
typedef  BOOL  (__stdcall*LibGT_InitChannels)(HANDLE ,_AIN ,_DIO );
typedef  BOOL  (__stdcall*LibGT_StartAcquisition)(HANDLE );
typedef  BOOL  (__stdcall*LibGT_StopAcquisition)(HANDLE );
typedef  BOOL  (__stdcall*LibGT_GetData)(HANDLE ,_BUFFER_ST* ,LPOVERLAPPED );
typedef  BOOL  (__stdcall*LibGT_GetDeviceStatus)(HANDLE , __DEVICESTATE*);
typedef  BOOL  (__stdcall*LibGT_SetTestmode)(HANDLE, BOOL);
typedef  BOOL  (__stdcall*LibGT_GetLastError)(UINT*);

typedef _AIN AIN;
typedef _BUFFER_ST BUFFER_ST;
typedef _DIO _DIO;
typedef _ERRSTR _ERRSTR;
typedef __CHANNEL __CHANNEL;
typedef __CFG __CFG;
typedef __DEVICESTATE __DEVICESTATE;
#endif
}

class gMobilab :	public Instrument
{
public:
	gMobilab(void);
	void *Entry(void);
	void StartDevice(wxString FileName,wxString FilePath,bool File);
	void StopDevice(void);
	int OpenPort(const char *PortName, const char *OpenVal2, const char *OpenVal3);

public:
	~gMobilab(void);

private:
#ifdef HAVE_GTEC_LIBRARY
	gMobilabPlus::LibGT_OpenDevice			hGT_OpenDevice;
	gMobilabPlus::LibGT_CloseDevice			hGT_CloseDevice;
	gMobilabPlus::LibGT_InitChannels		hGT_InitChannels;
	gMobilabPlus::LibGT_StartAcquisition	hGT_StartAcquisition;
	gMobilabPlus::LibGT_StopAcquisition		hGT_StopAcquisition;
	gMobilabPlus::LibGT_GetData				hGT_GetData;
	gMobilabPlus::LibGT_GetDeviceStatus		hGT_GetDeviceStatus;
	gMobilabPlus::LibGT_SetTestmode			hGT_SetTestmode;
	gMobilabPlus::LibGT_GetLastError		hGT_GetLastError;
#endif
	short buffer[256];
	HINSTANCE hinstLib;
	HANDLE hDevice, m_hEvent;
};

